<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="View Sales Quotation # #{salesQuotationEntityController.viewCurrent.id}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form rendered="#{loginBacking.viewSalesQuotation}">
                <p:panel header="View Sales Quotation # #{salesQuotationEntityController.viewCurrent.id}">
                    <p:messages />
                    <br />
                    <h:panelGrid columns="6">
                        <h:outputText value="Price Validity:" />
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.validity}" rendered="#{salesQuotationEntityController.viewCurrent.validity!=null}"/>
                        <h:outputText value="*Validity Period Not Set*" style="color:red" rendered="#{salesQuotationEntityController.viewCurrent.validity==null}"/>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="System User:" />
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.systemUser.firstName}&nbsp;#{salesQuotationEntityController.viewCurrent.systemUser.lastName}" rendered="#{salesQuotationEntityController.viewCurrent.systemUser!=null}"/>
                        <h:outputText value="*Price Not Quoted*" style="color:red" rendered="#{salesQuotationEntityController.viewCurrent.systemUser==null}"/>

                        <h:outputText value="Status:"/>
                        <h:outputText value="Invalid" rendered="#{salesQuotationEntityController.viewCurrent.valid==false}"/>
                        <h:outputText value="Valid" rendered="#{salesQuotationEntityController.viewCurrent.valid==true}"/>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="Indicative Lead Time:"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.indicativeLeadTime}" title="#{bundle.ViewSalesQuotationEntityTitle_indicativeLeadTime}" rendered="#{salesQuotationEntityController.viewCurrent.indicativeLeadTime!=null}"/>
                        <h:outputText value="*Date Not Given*" style="color:red" rendered="#{salesQuotationEntityController.viewCurrent.indicativeLeadTime==null}"/>

                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_salesLead}" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>
                        <p:commandLink ajax="false" value="#{salesQuotationEntityController.viewCurrent.salesLead.firstName}&nbsp;#{salesQuotationEntityController.viewCurrent.salesLead.lastName}" action="#{salesLeadEntityController.viewSalesLeadFromQuotation}" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>
                        <h:outputText value="" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>
                        <h:outputText value="" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>
                        <h:outputText value="Sales Lead Id:" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.salesLead}" rendered="#{salesQuotationEntityController.viewCurrent.salesLead!=null}"/>

                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_customer}" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}"/>
                        <p:commandLink ajax="false" value="#{salesQuotationEntityController.viewCurrent.customer.firstName}&nbsp;#{salesQuotationEntityController.viewCurrent.customer.lastName}" action="#{customerEntityController.viewCustomerFromQuotation}" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}"/>
                        <h:outputText value="" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}"/>
                        <h:outputText value="" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}"/>
                        <h:outputText value="Customer Id:" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}" />
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.customer}" rendered="#{salesQuotationEntityController.viewCurrent.customer!=null}"/>

                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_createdBy}"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.createdBy.firstName}&nbsp;#{salesQuotationEntityController.viewCurrent.createdBy.lastName}" title="#{bundle.ViewSalesQuotationEntityTitle_createdBy}"/>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_lastModifiedBy}"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.lastModifiedBy.firstName}&nbsp;#{salesQuotationEntityController.viewCurrent.lastModifiedBy.lastName}" title="#{bundle.ViewSalesQuotationEntityTitle_lastModifiedBy}"/>

                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_createdAt}"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.createdAt}" title="#{bundle.ViewSalesQuotationEntityTitle_createdAt}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="#{bundle.ViewSalesQuotationEntityLabel_lastModifiedAt}"/>
                        <h:outputText value="#{salesQuotationEntityController.viewCurrent.lastModifiedAt}" title="#{bundle.ViewSalesQuotationEntityTitle_lastModifiedAt}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>

                    </h:panelGrid>
                    <p:dataTable value="#{salesQuotationEntityController.viewCurrent.pqp}" var="pqp" style="border:solid 1px">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Product"/>
                            </f:facet>
                            <h:outputText value="#{pqp.product.productName}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:outputText value="#{pqp.quantity}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Price Per Unit (S$)"/>
                            </f:facet>
                            <h:outputText value="#{pqp.pricePerUnit}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Sub Total Price (S$)"/>
                            </f:facet>
                            <h:outputText value="#{pqp.price}"/>
                        </p:column>
                        <p:columnGroup type="footer">  
                            <p:row>  
                                <p:column colspan="3" footerText="Total Price:"  
                                          style="text-align:left"  />  

                                <p:column footerText="S$ #{salesQuotationEntityController.viewCurrent.totalPrice}" style="text-align:left" />  

                            </p:row>  
                        </p:columnGroup>
                    </p:dataTable>
                    <br />
                </p:panel>
                <p:panel header="Service Request(s)" toggleable="true" toggleSpeed="500" collapsed="true" rendered="#{salesQuotationEntityController.checkSystemUser()==true}">
                    <p:dataTable value="#{salesQuotationEntityController.selected.serviceRequests}" 
                                 var="sr" style="table-layout:fixed"
                                 paginator="true" rows="10"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Service Request"/>
                            </f:facet>
                            <h:outputText value="#{sr}"/>
                        </p:column>
                    </p:dataTable>
                </p:panel>
                <br />
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareCreatePO}" value="Make Purchase Order" rendered="#{salesQuotationEntityController.viewCurrent.valid==true}"/>
                <p:commandButton ajax="false" disabled="true" value="Make Purchase Order" rendered="#{salesQuotationEntityController.viewCurrent.valid==false}"/>
                &nbsp;
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareEditQuantity}" actionListener="#{salesQuotationEntityController.actionsFromViewCreate}" value="Edit Quotation"/>
                &nbsp;
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareCreate}" value="New Request For Quotation" />
                &nbsp;
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareList}" value="Show All Quotations"/>
                &nbsp;
                <p:menuButton value="Employees Actions" rendered="#{salesQuotationEntityController.checkSystemUser()==true}"> 
                    <p:menuitem ajax="false" icon="ui-icon ui-icon-pencil" action="Quote" actionListener="#{salesQuotationEntityController.actionsFromViewCreate}" value="Review" rendered="#{loginBacking.editSalesQuotation}"/>
                    <p:menuitem ajax="false" icon="ui-icon ui-icon-pencil" action="LeadTime" actionListener="#{salesQuotationEntityController.actionsFromViewCreate}" value="Set Lead Time" rendered="#{loginBacking.editSalesQuotation}"/>
                    <p:menuitem ajax="false" icon="ui-icon ui-icon-trash" action="#{salesQuotationEntityController.destroyAndView}" actionListener="#{salesQuotationEntityController.actionsFromViewCreate}" value="Delete" rendered="#{loginBacking.deleteSalesQuotation}"/>
                </p:menuButton>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
